<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="body-main">
    <!-- start-->
    <div class="dggui-panel">
        <table class="dggui-table-info">
            <tbody>
            <tr>
                <th>客户姓名:</th>
                <td>${order.customerName}</td>
                <th>流程人员:</th>
                <td>${order.flowUserName}</td>
                <th>生产事业部:</th>
                <td>${order.productOrgName}</td>
                <th>生产单编号:</th>
                <td>${order.scProductOrderNo}</td>
            </tr>
            </tbody>
        </table>
        <table class="dggui-table cell-border table-form" id="workEntryTable">
            <thead>
            <th>评估人员</th>
            <th>办理日期</th>
            <th>评估公司</th>
            <th>银行</th>
            <th>备注</th>
            <th>操作</th>
            </thead>
            <tbody>
            <tr>
                <td>${userEntity.realName}${userEntity.loginName}</td>
                <td>
                    <input type="text" readonly class="dggui-input dggui-time-range" name="handleTime">
                    <i class="iconfont icon-rili"></i>
                </td>
                <td><input type="text" name="assessmentCompany" class="dggui-input"></td>
                <td><input type="text" name="bank" class="dggui-input"></td>
                <td><input type="text" name="remark" class="dggui-input"></td>
                <td>
                    <a href="javascript:void(0)" class="dggui-link dggui-icon-btn" onclick="addQzlrRow(this)" title="添加"><i class="iconfont icon-tianjia"></i></a>
                    <a href="javascript:void(0)" class="dggui-icon-btn" onclick="removeTrRow(this)" title="删除"><i class="iconfont icon-shanchu"></i></a>
                </td>
            </tr>
            </tbody>
        </table>
        <input type="hidden" id="recordType" value="3" name="recordType">
        <input type="hidden" id="userId" value="${userEntity.id}" name="userId">
        <input type="hidden" id="scOrderId" value="${order.id}" name="scOrderId">
        <input type="hidden" id="orgId" value="${order.productOrgId}" name="orgId">
    </div>
    <!--生产人员 end-->
</div>
<script>
    function addQzlrRow(obj) {
        var trHtm='<tr>'+
            '<td>${userEntity.realName}${userEntity.loginName}</td>'+
            '<td>'+
            '<input type="text" readonly class="dggui-input dggui-time-range" name="handleTime">'+
            '<i class="iconfont icon-rili"></i>'+
            '</td>'+
            '<td><input type="text" name="assessmentCompany" class="dggui-input"></td>'+
            '<td><input type="text" name="bank" class="dggui-input"></td>'+
            '<td><input type="text" name="remark" class="dggui-input"></td>'+
            '<td>'+
            '<a href="javascript:void(0)" class="dggui-link dggui-icon-btn" onclick="addQzlrRow(this)" title="添加"><i class="iconfont icon-tianjia"></i></a>'+
            '<a href="javascript:void(0)" class="dggui-icon-btn" onclick="removeTrRow(this)" title="删除"><i class="iconfont icon-shanchu"></i></a>'+
            '</td>'+
            '</tr>';
        $(obj).parents('tr').after(trHtm);
        dgg.dialog.relocation(index);//弹框重新布局
        var initObj = $(obj).parents('tr').next().find('input[name = "handleTime"]')[0];
        dggui.dggdate.render({
            elem: initObj,
            trigger: 'click',
            type: 'date'
        });
        console.log()
    }

    function removeTrRow(obj) {
        if($(obj).parent().parent().parent().find("tr").length <= 1){
            dggui.dialog.errors("请至少保留一行");
        }else{
            $(obj).parents('tr').remove();
        }1
    }

    dggui.use(['dggdate'], function () {
        var dggdate = dggui.dggdate;
        //初始化日期下拉框
        //同时绑定多个
        lay('input[name = "handleTime"]').each(function () {
            dggdate.render({
                elem: this,
                trigger: 'click',
                type: 'date'
            });
        });
    });
</script>